home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / format.sty < prev    next >
Text File  |  1989-12-20  |  1KB  |  29 lines

  1. % Written by Charles Karney (Karney%PPC.MFENET@NMFECC.ARPA) 1986/04/29.
  2. % Format is a style option which allows the printing of floating point
  3. % numbers in fixed format.  The argument is the counter to use.  The
  4. % optional first argument if the power of ten to multiply counter by.  The
  5. % default is 0.  An integer is produced if power is nonnegative.
  6. % Otherwise, at least one digit appears before decimal point and exactly
  7. % -power digits after decimal point.  Restriction: abs(power)<=6.
  8. % Example: label an axis with -1.0, -0.8, -0.6, ... 1.0
  9. %     \newcounter{axis} \setcounter{axis}{-10}
  10. %     \multiput(...)(...){11}{\format[-1]{axis}\addtocounter{axis}{2}}
  11.  
  12. \def\format{\@ifnextchar[{\format@}{\format@[0]}}
  13. \def\format@[#1]#2{\@tempcnta#1 \@format{\@nameuse{c@#2}}}
  14. \def\@format#1{\hbox{$
  15.     \ifnum #1<0 - #1-#1\fi % Here's where to insert a +
  16.     \ifnum\@tempcnta<0
  17.         \@tempcnta-\@tempcnta
  18.         \@tempcnta\ifcase\@tempcnta\or 10 \or 100 \or 1000 \or
  19.                                     10000 \or 100000 \else 1000000 \fi
  20.         \@tempcntb#1 \divide\@tempcntb \@tempcnta
  21.         \number\@tempcntb . \multiply\@tempcntb \@tempcnta
  22.         \advance\@tempcntb -#1 \advance\@tempcnta -\@tempcntb
  23.         \expandafter\@gobble\number\@tempcnta
  24.     \else
  25.         \number #1
  26.         \ifcase\@tempcnta\or 0\or 00\or 000\or
  27.                          0000\or 00000\else 000000\fi\fi$}}
  28.